import sys
sys.path.append("../main/")
import unittest
from layout import RESTAPILayout

class testLayout(unittest.TestCase):

    def setUp(self):
        self.layout = RESTAPILayout("../../config/jira-layout.xml")

    def testAddVariables(self):
        query = "avatar/{type}/system"
        variables = ["queue"]
        output = self.layout.addVariables(query, variables)
        print output
        self.assertTrue(output == "avatar/queue/system")

    def testVariable(self):
        query = ["type", "queue"]
        output = self.layout.parseTree(query, [], self.layout.getRoot())
        self.assertTrue(output == "avatar/queue")

    def testScope(self):
        query = ["avatar"]
        output = self.layout.parseTree(query, [], self.layout.getRoot())
        self.assertTrue(output == "avatar")

    def testParse(self):
        query = "type queue"
        output = self.layout.parse(query)
        self.assertTrue(output == "avatar/queue")
        query = "issue issueid test assignee test new"
        output = self.layout.parse(query)
        self.assertTrue(output == "issues/test/assignee/new")
        query = "issue issueid test assignee test new new"
        output = self.layout.parse(query)
        print output
        self.assertTrue(output == "issues/test/assignee/new/new")



if __name__ == '__main__':
    unittest.main()

